﻿using UnityEngine;
using System.Collections;
using UnityEngine.Networking;

public class EnemySpawner : NetworkBehaviour
{
    public GameObject enemyPrefab;

    public int numOfEnemies;

    public override void OnStartServer()
    {
        for (int i = 0; i < numOfEnemies; ++i)
        {
            var spwanPosition = new Vector3(Random.Range(-8.0f, 8.0f), 
                0.0f, Random.Range(-8.0f, 8.0f));

            var spawnRotation = Quaternion.Euler(0.0f, Random.Range(0, 180), 0.0f);

            var enemy = (GameObject) Instantiate(enemyPrefab, spwanPosition, spawnRotation);

            NetworkServer.Spawn(enemy);
        }
    }
}